package k.daniel.databindingdemo.bean;

import android.databinding.ObservableBoolean;
import android.databinding.ObservableField;
import android.databinding.ObservableInt;
import android.widget.Toast;

import k.daniel.databindingdemo.AppContext;

/**
 * Created by daniel on 2016/4/27.
 */
public class UserBean {
    public ObservableField<String> firstName=new ObservableField<>();
    public ObservableField<String> lastName=new ObservableField<>();
    public ObservableInt age=new ObservableInt();
    public ObservableBoolean gender=new ObservableBoolean();

    public UserBean(String firstName, String lastName, int age, boolean gender) {
        this.firstName.set(firstName); ;
        this.lastName.set(lastName);
        this.age = new ObservableInt(age);
        this.gender.set(gender);
    }


    public void setFirstName(String firstName) {
        this.firstName.set(firstName);
        Toast.makeText(AppContext.getContext(),"First Name 变了", Toast.LENGTH_SHORT).show();
    }


    public void setLastName(ObservableField<String> lastName) {
        this.lastName = lastName;
        Toast.makeText(AppContext.getContext(),"Last Name 变了", Toast.LENGTH_SHORT).show();
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "firstName='" + firstName + '\'' +
                ", lastName='" + lastName + '\'' +
                ", age=" + age +
                ", gender=" + gender +
                '}';
    }
}
